package com.hengpeng.common.scheduling.quartz;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.hengpeng.common.scheduling.Command;
import com.hengpeng.common.scheduling.ScheduleConfig;

public class SingleTonCommandJobBean extends QuartzJobBean implements StatefulJob
{
	private static final Log logger = LogFactory.getLog(SingleTonCommandJobBean.class);

	private Command command;

	private ScheduleConfig config;

	protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException
	{
		try
		{
			command.excute(config);
		}
		catch (Exception e)
		{
			logger.error("任务调度的业务逻辑异常", e);
		}
	}

	public ScheduleConfig getConfig()
	{
		return config;
	}

	public void setConfig(ScheduleConfig config)
	{
		this.config = config;
	}

	public Command getCommand()
	{
		return command;
	}

	public void setCommand(Command command)
	{
		this.command = command;
	}
}
